<%@ page language="java" import="java.util.*,gameserver.*,modle.Stadium,servlet.StartSocketServlet" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">

	<meta http-equiv="description" content="This is my page">
	
	<script type="text/javascript" src="jquery-1.7.2.js"></script>
	
<script type="text/javascript">
	
	function getinfo(){
		$.get(
			"getRoomsNumAjax",
			{},
			function(data,status){
				if(status == "success"){
					//alert(data.length);
					var rooms = document.getElementsByName("rooms").valueOf();
					//alert(rooms[0].innerHTML);
					for(var i=0; i<rooms.length; i++){
						rooms[i].innerHTML ="人数: " + data[rooms[i].title - 1];
					}
					
				}
			}
		);
		
		setTimeout('getinfo()',10000);
	}

	$(getinfo());
	

</script>  
	
	<style type="text/css">
		ul li:HOVER {
			color: blue;
			cursor: pointer;
		}
		
		.roomDiv{
			float:left;
			width: 200px;
			height: 100px;
			background-color: gray;
			margin: 5px;
		}
		
		.roomDiv:HOVER {
			cursor: pointer;
			background-color: #49CCFA;
		}
		
	</style>
  </head>
  
  <body>


欢迎你：
 <%
 String username = (String)session.getAttribute("username");
 if(username != null)
	 out.println(username);
 else{
	 out.println(session.getAttribute("guestName"));
 %>
 <p>
  	系统为你分配了一个名字 。<a target="view_window"
  	href="http://10.5.82.203/Joomla/index.php/using-joomla/extensions/components/users-component/registration-form">点击这里注册</a>
  	</p>
  	<% 
 }
  	ArrayList<Stadium> roomsList = (ArrayList<Stadium>)request.getAttribute("rooms");
  	
  	
  	for(Stadium s:roomsList){
  	%>
  	<div class="roomDiv">
  		
  		<%=s.getStadiumLocalName() %> &nbsp;<br>
  		
  		<label name="rooms" title="<%=s.getStadiumId()%>">人数：<%=StartSocketServlet.socketServerList.get(s.getStadiumId()-1).clientList.size() %> </label>
  		<br>
  		<a href="JoinRoomServlet?roomId=<%=s.getStadiumId()%>"  target="_blank" >进入游戏</a>
  		
  	</div>
  	<%
  	} 
  	%>
  	

  <%--
  	<table>
  		<tr align="center">
  			
  		</tr>
  		<tr align="left">
  			<td>
  				<ul>
  				<s:iterator value="stadium" var="rooms">
  					<li >
  					<a href="room.action?roomid=<s:property value='id'/>">hello</a>
  					</li>
  				</s:iterator>
  				</ul>
  			</td>
  		
  		</tr>
  	</table>
  --%>
  </body>
</html>
